package com.vcyber.wty.configure;

import com.vcyber.wty.service.impl.InvoiceServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnWebApplication
@EnableConfigurationProperties(InvoiceProperties.class)
public class InvoiceServiceAutoConfiguration {

    @Autowired
    private InvoiceProperties invoiceProperties;

    @Bean
    @ConditionalOnMissingBean(InvoiceServiceImpl.class)
    public InvoiceServiceImpl invoiceServiceImpl() {
        InvoiceServiceImpl invoiceServiceImpl = new InvoiceServiceImpl();
        invoiceServiceImpl.setInvoiceProperties(invoiceProperties);
        return invoiceServiceImpl;
    }
}
